/**
 *获取本地存储
 * @param {String} key {本地存储的名字}
 * @returns {string|any}
 */
export function getItem (key) {
  const data = localStorage.getItem(key)
  try {
    return JSON.parse(data)
  } catch (e) {
    return data
  }
}

/**
 * 存储本地数据
 * @param {String} key
 * @param {$Values} val
 */
export function setItem (key, val) {
  if (typeof val === 'object') val = JSON.stringify(val)
  localStorage.setItem(key, val)
}

/**
 * 删除本地数据
 * @param key
 */

export function removeItem (key) {
  localStorage.removeItem(key)
}
